package cn.chenhuanming.chuanzhi.util.entity;// default package

import cn.chenhuanming.chuanzhi.util.entity.converter.LocalDateConverter;
import cn.chenhuanming.chuanzhi.util.entity.converter.LocalDateTimeConverter;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;
import static javax.persistence.GenerationType.SEQUENCE;

/**
 * Share entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "share", catalog = "website")
@DynamicUpdate
@DynamicInsert
public class Share implements java.io.Serializable {

	// Fields

	private String id;
	private Staff staff;
	private String title;
	private String description;
	private String content;
	@JsonFormat(pattern = "yyyy-MM-dd")
	private LocalDateTime publishTime;
	@JsonFormat(pattern = "yyyy-MM-dd")
	private LocalDateTime lastTime;

	// Constructors

	/** default constructor */
	public Share() {
	}

	/** full constructor */
	public Share(String id,Staff staff, String title,String description, String content,
				 LocalDateTime publishTime, LocalDateTime lastTime) {
		this.id = id;
		this.staff = staff;
		this.title = title;
		this.description = description;
		this.content = content;
		this.publishTime = publishTime;
		this.lastTime = lastTime;
	}

	// Property accessors
	@Id
	@GeneratedValue(generator = "UUID")
	@GenericGenerator(
			name = "UUID",
			strategy = "org.hibernate.id.UUIDGenerator"
	)
	@Column(name = "id", unique = true, nullable = false, length = 36)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "author")
	public Staff getStaff() {
		return this.staff;
	}

	public void setStaff(Staff staff) {
		this.staff = staff;
	}

	@Column(name = "title")
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "description")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "content")
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Convert(converter = LocalDateTimeConverter.class)
	@Column(name = "publish_time", length = 19)
	public LocalDateTime getPublishTime() {
		return this.publishTime;
	}

	public void setPublishTime(LocalDateTime publishTime) {
		this.publishTime = publishTime;
	}

	@Convert(converter = LocalDateTimeConverter.class)
	@Column(name = "last_time", length = 19)
	public LocalDateTime getLastTime() {
		return this.lastTime;
	}

	public void setLastTime(LocalDateTime lastTime) {
		this.lastTime = lastTime;
	}

}